<?php Schema::init(); ?>
<div class="schema_wrapper">
	<?php if ($error != -1) { ?>
		<div class="schema_message">
		<?php if (!$error) {
			Backend::infoMessage(__('Category updated successfully'));
		} else if ($error == -2) {
			Backend::infoMessage(__('Category inserted successfully'));
		} else {
			Backend::errorMessage(__('Error updating category'));
		} ?>
		</div>
	<?php } ?>

	<div class="schema_header">
		<?php echo __('Updating category "{%category_name%}"', array('category_name' => $info['name'])); ?>
	</div>
	<form action="<?php echo CURRENT_URL, $info['id']; ?>" method="post">
		<div class="schema_tabs">
			<ul class="nav nav-pills">
				<li id="schema_tab_0" class="active">
					<a href="#0" onclick="Core.Schema.openTab(0)"><?php echo __('General'); ?></a>
				</li>
			<?php Schema::drawTabs('category.xml'); ?>
			</ul>
		</div>
		<div class="schema_blocks">
			<div class="schema_block" id="schema_block_0">
				<table class="table">
					<colgroup>
						<col class="schema_column_headers" />
						<col class="schema_column_fields" />
					</colgroup>
					<tbody>
						<tr>
							<td class="schema_cell_header"><?php echo __('Category name'); ?></td>
							<td class="schema_cell_field"><input type="text" name="cat_name" value="<?php echo Schema::clearValue($info['name']); ?>" class="schema_textfield" /></td>
						</tr>
						<tr>
							<td class="schema_cell_header"><?php echo __('Alias'); ?></td>
							<td class="schema_cell_field"><input type="text" name="cat_alias" value="<?php echo Schema::clearValue($info['alias']); ?>" class="schema_textfield" /></td>
						</tr>
						<tr>
							<td class="schema_cell_header"><?php echo __('Status'); ?></td>
							<td class="schema_cell_field">
								<select name="cat_status_id" class="schema_select">
									<option value="1"<?php if (1 == intval($info['status_id'])) { ?> selected="selected"<?php } ?>><?php echo __('Opened'); ?></option>
									<option value="2"<?php if (2 == intval($info['status_id'])) { ?> selected="selected"<?php } ?>><?php echo __('Closed'); ?></option>
								</select>
							</td>
						</tr>
						<tr>
							<td class="schema_cell_header"><?php echo __('Parent category'); ?></td>
							<td class="schema_cell_field">
								<select name="cat_parent_id" class="schema_select">
									<?php Category::drawTreeSelect($info['type_id'], $info['parent_id'], $info['id']); ?>
								</select>
							</td>
						</tr>
					<?php if (intval($info['insert_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Inserted by'); ?></td>
							<td class="schema_cell_field"><?php echo User::getName($info['insert_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['insert_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Inserted at'); ?></td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['insert_time']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['update_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Updated by'); ?></td>
							<td class="schema_cell_field"><?php echo User::getName($info['update_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['update_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Updated at'); ?></td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['update_time']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['delete_user_id']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Deleted by'); ?></td>
							<td class="schema_cell_field"><?php echo User::getName($info['delete_user_id']); ?></td>
						</tr>
					<?php } ?>

					<?php if (intval($info['delete_time']) > 0) { ?>
						<tr>
							<td class="schema_cell_header"><?php echo __('Deleted at'); ?></td>
							<td class="schema_cell_field"><?php echo User::getDate(User::getId(), $info['delete_time']); ?></td>
						</tr>
					<?php } ?>
					</tbody>
				</table>
			</div>
			<?php Schema::drawBlocks('category.xml', 'tbl_categories_fields', 'category_id', $info['id']); ?>
		</div>
		<div class="schema_buttons"><input type="submit" value="<?php echo __('Update'); ?>" class="btn btn-primary" /></div>
	</form>
</div>